package com.qf.sys.service.impl;

import com.qf.entity.sys.SysUser;
import com.qf.exception.CustomerException;
import com.qf.sys.dao.SysUserDAO;
import com.qf.sys.param.LoginParam;
import com.qf.sys.service.SysUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * ==== 天道酬勤 ====
 *
 * @author douzhouzhou
 * @date 2025/2/26
 * <p>
 * ==== 行稳致远 进而有为 ====
 */
@Service
public class SysUserServiceImpl implements SysUserService {
    @Resource
    private SysUserDAO sysUserDAO;
    @Override
    public SysUser login(LoginParam loginParam) {
        SysUser sysUser = sysUserDAO.selectByUserName(loginParam.getUsername());
        if (sysUser == null){ // 用户不存在
            throw new CustomerException("5001","用户不存在");
        }
        if (!(sysUser.getPassword().equals(loginParam.getPassword()))){
            throw new CustomerException("5002","密码错误");
        }
        return sysUser;
    }
}
